/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Registro.java
 *
 * Created on 6/05/2009, 11:04:41 PM
 */

package gui;


import Multimedia.MediaSonido;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
//import org.jvnet.substance.SubstanceLookAndFeel;
//import org.jvnet.substance.watermark.SubstanceImageWatermark;
import javazoom.jlgui.basicplayer.BasicPlayerException;
import org.xml.sax.SAXException;
import persistencia.Ingreso;

/**
 *
 * @author arquitectura
 */


public class Login extends javax.swing.JFrame {
private Ingreso ic;
public  MediaSonido sonidoLogin = new MediaSonido();

    /** Creates new form Registro */
    public Login() {
        initComponents();

        //Manejo de Graficos
        xPnlFondo pnlFondo = new xPnlFondo(8);
        this.add (pnlFondo);
        this.pack();
        
        this.setSize(800, 600);
        //GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
        this.setLocationRelativeTo(null);

        //Manejo de Sonido
        
        try {
            sonidoLogin.loadFile("C:/Documents and Settings/Arquitectura/Escritorio/Track_Login.mp3");
            sonidoLogin.play();
        } catch (BasicPlayerException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }

        ic= new Ingreso();
      
    }

    public JButton getBTN_entrar() {
        return BTN_entrar;
    }

    public void setBTN_entrar(JButton BTN_entrar) {
        this.BTN_entrar = BTN_entrar;
    }

    public JButton getBTN_registrarse() {
        return BTN_registrarse;
    }

    public void setBTN_registrarse(JButton BTN_registrarse) {
        this.BTN_registrarse = BTN_registrarse;
    }

    public JTextField getJTF_contrasena() {
        return JTF_contrasena;
    }

    public void setJTF_contrasena(JTextField JTF_contrasena) {
        this.JTF_contrasena = (JPasswordField) JTF_contrasena;
    }

    public JTextField getJTF_username() {
        return JTF_username;
    }

    public void setJTF_username(JTextField JTF_username) {
        this.JTF_username = JTF_username;
    }

    public Ingreso getIc() {
        return ic;
    }

    public void setIc(Ingreso ic) {
        this.ic = ic;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BTN_entrar = new javax.swing.JButton();
        JTF_username = new javax.swing.JTextField();
        BTN_registrarse = new javax.swing.JButton();
        JTF_contrasena = new javax.swing.JPasswordField();
        JTF_ip = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Login");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(java.awt.Color.white);
        setResizable(false);
        setUndecorated(true);

        BTN_entrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/volverahome.png"))); // NOI18N
        BTN_entrar.setBorder(null);
        BTN_entrar.setBorderPainted(false);
        BTN_entrar.setContentAreaFilled(false);
        BTN_entrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_entrarActionPerformed(evt);
            }
        });

        JTF_username.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        JTF_username.setForeground(new java.awt.Color(204, 204, 204));
        JTF_username.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        JTF_username.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        JTF_username.setOpaque(false);

        BTN_registrarse.setText("                       ");
        BTN_registrarse.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        BTN_registrarse.setBorderPainted(false);
        BTN_registrarse.setContentAreaFilled(false);

        JTF_contrasena.setForeground(new java.awt.Color(204, 204, 204));
        JTF_contrasena.setBorder(null);
        JTF_contrasena.setCaretColor(new java.awt.Color(172, 168, 153));
        JTF_contrasena.setOpaque(false);

        JTF_ip.setForeground(new java.awt.Color(204, 204, 204));
        JTF_ip.setBorder(null);
        JTF_ip.setOpaque(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(JTF_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(404, 404, 404)
                        .addComponent(JTF_contrasena, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(391, 391, 391)
                        .addComponent(BTN_entrar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(327, 327, 327)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(BTN_registrarse, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(JTF_username, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))))
                .addContainerGap(38, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(182, 182, 182)
                .addComponent(JTF_username, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(BTN_registrarse, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JTF_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JTF_contrasena, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(105, 105, 105)
                .addComponent(BTN_entrar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(162, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
    }// </editor-fold>//GEN-END:initComponents

    private void BTN_entrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_entrarActionPerformed
        try {
            this.ic.entrar(this,sonidoLogin,JTF_ip.getText());
            /*
            this.ic.entrar(this);//GEN-LAST:event_BTN_entrarActionPerformed
            */
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        } catch (XPathExpressionException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }                                          

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {

        //JFrame.setDefaultLookAndFeelDecorated(true);

        //SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        //SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/Login.jpg"));
        //SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Login().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BTN_entrar;
    private javax.swing.JButton BTN_registrarse;
    private javax.swing.JPasswordField JTF_contrasena;
    private javax.swing.JTextField JTF_ip;
    private javax.swing.JTextField JTF_username;
    // End of variables declaration//GEN-END:variables

}
